package com.ruoyi.fun.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.fun.mapper.EcAdvertisementMapper;
import com.ruoyi.fun.domain.EcAdvertisement;
import com.ruoyi.fun.service.IEcAdvertisementService;

/**
 * 广告列Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-08-08
 */
@Service
public class EcAdvertisementServiceImpl implements IEcAdvertisementService 
{
    @Autowired
    private EcAdvertisementMapper ecAdvertisementMapper;

    /**
     * 查询广告列
     * 
     * @param adId 广告列主键
     * @return 广告列
     */
    @Override
    public EcAdvertisement selectEcAdvertisementByAdId(Long adId)
    {
        return ecAdvertisementMapper.selectEcAdvertisementByAdId(adId);
    }

    /**
     * 查询广告列列表
     * 
     * @param ecAdvertisement 广告列
     * @return 广告列
     */
    @Override
    public List<EcAdvertisement> selectEcAdvertisementList(EcAdvertisement ecAdvertisement)
    {
        System.out.println("[DEBUG] EcAdvertisementServiceImpl.selectEcAdvertisementList - 查询参数 orgId: " + ecAdvertisement.getOrgId());
        List<EcAdvertisement> result = ecAdvertisementMapper.selectEcAdvertisementList(ecAdvertisement);
        System.out.println("[DEBUG] EcAdvertisementServiceImpl.selectEcAdvertisementList - 查询结果数量: " + result.size());
        for (EcAdvertisement ad : result) {
            System.out.println("[DEBUG] EcAdvertisementServiceImpl.selectEcAdvertisementList - 广告ID: " + ad.getAdId() + ", orgId: " + ad.getOrgId());
        }
        return result;
    }

    /**
     * 新增广告列
     * 
     * @param ecAdvertisement 广告列
     * @return 结果
     */
    @Override
    public int insertEcAdvertisement(EcAdvertisement ecAdvertisement)
    {
        ecAdvertisement.setCreateTime(DateUtils.getNowDate());
        ecAdvertisement.setOrgId(SecurityUtils.getDeptId());
        return ecAdvertisementMapper.insertEcAdvertisement(ecAdvertisement);
    }

    /**
     * 修改广告列
     * 
     * @param ecAdvertisement 广告列
     * @return 结果
     */
    @Override
    public int updateEcAdvertisement(EcAdvertisement ecAdvertisement)
    {
        ecAdvertisement.setUpdateTime(DateUtils.getNowDate());
        return ecAdvertisementMapper.updateEcAdvertisement(ecAdvertisement);
    }

    /**
     * 批量删除广告列
     * 
     * @param adIds 需要删除的广告列主键
     * @return 结果
     */
    @Override
    public int deleteEcAdvertisementByAdIds(Long[] adIds)
    {
        return ecAdvertisementMapper.deleteEcAdvertisementByAdIds(adIds);
    }

    /**
     * 删除广告列信息
     * 
     * @param adId 广告列主键
     * @return 结果
     */
    @Override
    public int deleteEcAdvertisementByAdId(Long adId)
    {
        return ecAdvertisementMapper.deleteEcAdvertisementByAdId(adId);
    }

    /**
     * 根据adId和组织ID查询Advertisement
     * 
     * @param adId Advertisement主键
     * @param orgId 组织ID
     * @return Advertisement
     */
    @Override
    public EcAdvertisement selectEcAdvertisementByAdIdAndOrgId(Long adId, Long orgId)
    {
        return ecAdvertisementMapper.selectEcAdvertisementByAdIdAndOrgId(adId, orgId);
    }

    /**
     * 根据组织ID查询Advertisement列表
     * 
     * @param ecadvertisement Advertisement
     * @param orgId 组织ID
     * @return Advertisement集合
     */
    @Override
    public List<EcAdvertisement> selectEcAdvertisementListByOrgId(EcAdvertisement ecadvertisement, Long orgId)
    {
        return ecAdvertisementMapper.selectEcAdvertisementListByOrgId(ecadvertisement, orgId);
    }
}